<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>问题反馈平台</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!-- 引入css -->
<link href="/ksp/layui/css/layui.css" rel="stylesheet">
<!-- 引入js -->
<script type="text/javascript" src="/ksp/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/ksp/layui/layui.all.js"></script>
<!-- 自定义js -->
<script type="text/javascript" src="/ksp/js/ksp.com.js"></script>
<script type="text/javascript">
	var element;
	var table;
	var layer;
	layui.use([ 'element', 'table', 'layer' ], function() {
		element = layui.element;
		table = layui.table;
		layer = layer;
	});

	/* 初始化任务列表 */
	function iniTskTbl() {
		table.render({
			elem : "#tbTskLst"
			,url : "/ksp/tsk/KSPT02B"
			,cellMinWidth : 95
			
			,limits : [10,20,50]
			,limit : 10
			,id : "tableTskLst"
			,cols : [[
	          {checkbox : true, fixed : true}
	          ,{field : "TCH_IDN", width : 80, title : "任务id", sort :true}
	          ,{field : "KSP_TTL", width : 80, title : "任务主题", sort : true}
	          ,{field : "KSP_CON", width : 80, title : "任务详细说明", sort : true}
	          ,{field : "IMP_DEG", width : 80, title : "任务重要级别", sort : true}
	          ,{field : "DEA_USR", width : 80, title : "任务处理人员", sort : true}
	          ,{field : "DEA_UNM", width : 80, title : "任务处理人员姓名", sort : true}
	          ,{field : "TSK_STS", width : 80, title : "任务处理状态", sort : true}
	          ,{field : "TSK_TYP", width : 80, title : "任务类别", sort : true}
	          ,{field : "QUA_USR", width : 80, title : "问题反馈人员", sort : true}
	          ,{field : "QUA_UNM", width : 80, title : "问题反馈人员姓名", sort : true}
	          ,{field : "QUA_DBG", width : 80, title : "问题提出时间", sort : true}
	          ,{field : "MNT_DAT", width : 80, title : "最后修改时间", sort : true}
	          ,{field : "SPC_RMK", width : 80, title : "备注信息", sort : true}
	          ,{field : "center", width : 150, title : "操作", toolbar : "#barDemo"} 
	      
	         ]]
			,page : true
		});
		
		table.on("checkbox(useruv)", function(obj) {
			console.log(obj);
		});
		
		table.on("tool(useruv)", function(obj) {
			var tskDta = obj.data;
			switch(obj.event) {
			case "detail" : {
				var KSP_TTL = tskDta.KSP_TTL;
				var KSP_CON = tskDta.KSP_CON;
				var SPC_RMK = tskDta.SPC_RMK;
				var QUA_UNM = tskDta.QUA_UNM;
				var QUA_DBG = tskDta.QUA_DBG;
				var DEA_UNM = tskDta.DEA_UNM;
				var MNT_DAT = tskDta.MNT_DAT;
				
				if (typeof(SPC_RMK) == "undefined") {SPC_RMK = "no";}
				if (typeof(QUA_UNM) == "undefined") {QUA_UNM = "no";}
				if (typeof(QUA_DBG) == "undefined") {QUA_DBG = "no";}
				if (typeof(DEA_UNM) == "undefined") {DEA_UNM = "no";}
				if (typeof(MNT_DAT) == "undefined") {MNT_DAT = "no";}
				
				tskInfHtml = '<div style="padding:10px;"><div>标题:' + KSP_TTL + '</div>'
					+ '<div>内容:' + KSP_CON + '</div>'
					+ '<hr/><div>解决方法:' + SPC_RMK + '</div>'
					+ '<div>反馈人:' + QUA_UNM + '</div>'
					+ '<div>反馈时间:' + QUA_DBG + '</div>'
					+ '<div>处理人:' + DEA_UNM + '</div>'
					+ '<div>处理时间:' + MNT_DAT + '</div>';
				layer.open({
					 type : 1
					,area : ['800px', '600px']
					,title : "任务详情查看"
					,content : tskInfHtml
					,shadeClose : true
					,maxmin : true
				});
					
				}break;
			case "edit" : {
				window.location.href = "/ksp/p/tsk/tskopr?t=e&id=" + tskDta.TCH_IDN;
			}break;
			case "del" : {
				layer.confirm("确认删除吗？", {btn : ['确定', '取消']}
					,function() {
						$.ajax({
							url : "/ksp/tsk/KSPT04"
							,type : "post"
							,dataType : "json"
							,data : {"TCH_IDN" : tskDta.TCH_IDN}
							,async : true
							,success : function (res) {
								if (res.cod == "200") {
									layer.msg("已删除", {time:1000});
									$("#bSearch").click();
								}
							}
						});
					}
					,function() {
						layer.closeAll();
					}
				);
			}break;
			default:break;
		}});
		
		var active = {
			getChecklenth : function() {
				var chkItem = table.checkStatus('tableTskLst'),
				    data = chkItem.data;
				var chkTskTchStr = "";
				for (var i = 0; i < data.length; i++) {
					var tsk = data[i];
					chkTskTchStr += tsk.TCH_IDN + ",";
				}
				alert(chkTskTchStr + "共" + data.length + "条记录");
			}
			,qryTskLst : function() {
				var txtCon = $("#txtTskCon").val();
				table.reload("tableTskLst", {
					url : "/ksp/tsk/KSPT02B"
					,where : {
						"KSP_CON" : txtCon
					}
					
				});
			},addTsk : function() {
				window.location.href = "/ksp/p/tsk/tskopr?t=a&id=";
			}
		};
		
		$(".layui-btn").on("click", function() {
			var type = $(this).data("type");
			active[type] ? active[type].call(this) : "";
			
		});
		
	};
	
</script>
<!-- html初始化后加载js -->
<script type="text/javascript">
	$(function() {
		iniNar();
		iniTskTbl();
		
	});
</script>

</head>
<body>
	<!-- 导航栏 -->
	<div id="navDiv"></div>
	<div style="margin-top: 20px; margin-left: 20px;">
		<div>
			<button class="layui-btn" data-type="getChecklenth">批处理</button>
			按模板名称搜索：
			<div class="layui-inline">
				<input class="layui-input" id="txtTskCon" autocomplete="off">
			</div>
			<button class="layui-btn" data-type="qryTskLst" id="bSearch">搜索</button>
			<button class="layui-btn" data-type="addTsk">新增</button>
		</div>
		<table id="tbTskLst" lay-filter="useruv"></table>

		<script type="text/html" id="barDemo">
			<a class="layui-btn-mini layui-btn-primary" lay-event="detail">查看</a>
			<a class="layui-btn-mini layui-btn-primary" lay-event="edit">编辑</a>
			<a class="layui-btn-mini layui-btn-primary" lay-event="del">删除</a>
		</script>
	</div>

</body>
</html>